package com.syxd.controller;

import com.syxd.common.annotation.LogOperation;
import com.syxd.common.constant.Constant;
import com.syxd.common.entity.WebResult;
import com.syxd.common.utils.PageData;
import com.syxd.dto.SysCreditDto;
import com.syxd.dto.SysPermissionDTO;
import com.syxd.service.SysCreditMasterService;
import io.swagger.annotations.*;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.Map;

@RestController
@RequestMapping("sys/Credit")
@Api(tags="贷款平台主业务")
public class SysCreditMasterController {
@Autowired
SysCreditMasterService sysCreditMasterService;
    @GetMapping("page")
    @ApiOperation("分页")
    @ApiImplicitParams({
            @ApiImplicitParam(name = Constant.PAGE, value = "当前页码，从1开始", paramType = "query", required = true, dataType="int") ,
            @ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataType="int") ,
            @ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataType="String") ,
            @ApiImplicitParam(name = Constant.ORDER, value = "排序方式，可选值(asc、desc)", paramType = "query", dataType="String")
    })
    @LogOperation(apiType = "Credit",apiPath = "sys/Credit/page")
    @RequiresPermissions("Credit:page")
    public WebResult<PageData<SysPermissionDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
        /*PageData<SysPermissionDTO> page = sysCreditMasterService.page(params);*/

/*
        return new WebResult<PageData<SysPermissionDTO>>().ok(page);
*/

        return null;
    }
    /**
     * 查询户主额度
     */
    @GetMapping("query")
    @ApiOperation("查询户主额度")
    @ApiImplicitParams({

            @ApiImplicitParam(name = "householderName", value = "户主名字", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "householderIdcard", value = "户主身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "householderPhone", value = "户主手机号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spouseName", value = "配偶姓名", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "spouseIdcard", value = "配偶身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spousePhone", value = "配偶手机号", paramType = "query", dataType="int")

    })
    @RequiresPermissions("public:query")
    public WebResult queryHouseholdQuota(@ApiIgnore @RequestParam Map<String, Object> params){
        SysCreditDto sysCreditDto = new SysCreditDto();
        if (params.get("householderName")!=null){
            sysCreditDto.setHouseholderName((String) params.get("householderName"));
        }if (params.get("householderIdcard")!=null){
            sysCreditDto.setHouseholderIdcard((Integer) params.get("householderIdcard"));
        }if (params.get("householderPhone")!=null){
            sysCreditDto.setHouseholderPhone((Integer) params.get("householderPhone"));
        }if (params.get("spouseName")!=null){
            sysCreditDto.setSpouseName((String) params.get("spouseName"));
        }if (params.get("spousePhone")!=null){
            sysCreditDto.setSpousePhone((Integer) params.get("spousePhone"));
        }if (params.get("spouseIdcard")!=null){
            sysCreditDto.setSpouseIdcard((Integer) params.get("spouseIdcard"));
        }

        return   sysCreditMasterService.queryHouseholdQuota(sysCreditDto);

    }
    @GetMapping("queryJiang")
    @ApiOperation("查询户主匠信贷信息")
    @ApiImplicitParams({

            @ApiImplicitParam(name = "householderName", value = "户主名字", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "householderIdcard", value = "户主身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "householderPhone", value = "户主手机号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spouseName", value = "配偶姓名", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "spouseIdcard", value = "配偶身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spousePhone", value = "配偶手机号", paramType = "query", dataType="int")

    })
    @RequiresPermissions("public:queryjiang:info:")
  public WebResult queryJiangCredit(@ApiIgnore @RequestParam Map<String, Object> params){
     return    sysCreditMasterService.queryJiangCredit(params);

  }

    @GetMapping("querySun")
    @ApiOperation("查询户主阳光信贷信息")
    @ApiImplicitParams({

            @ApiImplicitParam(name = "householderName", value = "户主名字", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "householderIdcard", value = "户主身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "householderPhone", value = "户主手机号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spouseName", value = "配偶姓名", paramType = "query", dataType="String"),
            @ApiImplicitParam(name = "spouseIdcard", value = "配偶身份证号", paramType = "query", dataType="int"),
            @ApiImplicitParam(name = "spousePhone", value = "配偶手机号", paramType = "query", dataType="int")

    })
    @RequiresPermissions("public:querysun:info:")
    public WebResult querySunCredit(@ApiIgnore @RequestParam Map<String, Object> params){
        return    sysCreditMasterService.querySunCredit(params);
    }
    




}
